﻿namespace Tszy.Unlimited.Base.Extensions.Code;

/// <summary>
/// Json 代码扩展。
/// </summary>
public static class JsonCodeExtensions
{
    /// <summary>
    /// 将代码字符串转成 HTML 格式。
    /// </summary>
    /// <param name="source"></param>
    /// <returns></returns>
    public static string GetJsonCode(this string source)
    {
        return source.Replace("\r\n", "<br/>").Replace(" ", "&nbsp;");
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="source"></param>
    /// <returns></returns>
    public static string GetTextCode(this string source)
    {
        return source.Replace("\r\n", "<br/>").Replace(" ", "&nbsp;");
    }
}
